package org.coody.gitee.handle;

import java.text.MessageFormat;

import org.coody.gitee.config.FuzzerConfig;
import org.coody.gitee.util.HttpUtil;
import org.coody.gitee.util.HttpUtil.HttpEntity;
import org.coody.gitee.util.StringUtil;

public class VerCodeHandle {



	public static String parseVercode(byte[] img) {
		String param = MessageFormat.format("username={0}&password={1}&typeid={2}&timeout={3}&softid={4}&softkey={5}",
				FuzzerConfig.ruokuaiUsername, FuzzerConfig.ruokuaiPassword, FuzzerConfig.ruokuaiTypeid, 60, FuzzerConfig.ruokuaiSoftid, FuzzerConfig.ruokuaiSoftkey);
		HttpEntity entity = HttpUtil.fileUpload(FuzzerConfig.ruokuaiUrl, param, img);
		if (StringUtil.isNullOrEmpty(entity) || entity.getCode() != 200) {
			return null;
		}
		String json = entity.getHtml();
		String result=StringUtil.textCutCenter(json, "Result\":\"", "\"");
		return result;
	}

}
